<template>
	<view class="control">
		<u-gap height="20rpx" bgColor="#EDF5F5"></u-gap>
		<view class="control_cen">
			<view class="con_bet">
				<view class="con_l">
					手环:
				</view>
				<view class="con_r">
					<input type="button" placeholder="输入手牌" class="con_btn" v-model="out_code" />
				</view>
			</view>
		</view>
		<view class="control_cen" v-if="overinfo == true">
			<view class="con_bet">
				<view class="con_l">
					类型:
				</view>
				<view class="con_r">
					{{overtimelist.type_text?overtimelist.type_text:''}}
				</view>
			</view>
			<view class="con_bet">
				<view class="con_l">
					进场时间:
				</view>
				<view class="con_r">
					{{overtimelist.created_at?overtimelist.created_at:''}}
				</view>
			</view>
			<view class="con_bet">
				<view class="con_l">
					出场时间:
				</view>
				<view class="con_r">
					{{current_year_month?current_year_month:''}}
				</view>
			</view>
			<view class="con_bet">
				<view class="con_l">
					超时时间:
				</view>
				<view class="con_r">
					{{overtimelist.overtime_minute?overtimelist.overtime_minute:''}}分钟
				</view>
			</view>
			<view class="con_bet">
				<view class="con_l">
					合计:
				</view>
				<view class="con_r" style="color: red;">
					¥{{overtimelist.overtime_fee?overtimelist.overtime_fee:''}}
				</view>
			</view>
		</view>
		<view class="go-btn" v-if="overinfo == false">
			<view class="on-btn">

			</view>
			<view class="btn" @click="ongetSwimInfo">
				查询
			</view>
		</view>
		<view class="go-btn" v-if="overinfo == true">
			<view class="on-btn">

			</view>
			<view class="btn" @click="gogetSwimInfo">
				支付
			</view>
		</view>
	</view>
</template>

<script>
	const person = require("@/api/personal/index.js");
	export default {
		data() {
			return {
				out_code: '',
				overtimelist: {},
				overinfo: false,
				current_year_month:'',
				orderlist:{},
				payWaitTime: '00:15:00',
			}
		},
		onLoad(options) {},

		methods: {
			getCurrentTime() {
				var _this = this
				var now = new Date()
				var y = now.getFullYear()
				var m = now.getMonth() + 1
				var d = now.getDate()
				var h = now.getHours(); //获取当前小时数(0-23)
				var min = now.getMinutes(); //获取当前分钟数(0-59)
				 var sec = now.getSeconds(); // 获取当前秒数 (0-59)
				if (m < 10) {
					m = '0' + m
				}
				if (d < 10) {
					d = '0' + d
				}
				if (h < 10) {
					h = '0' + h
				}
				if (min < 10) {
					min = '0' + min
				}
				 if (sec < 10) {
				    sec = '0' + sec;
				  }
				_this.current_year_month = y + '-' + m + '-' + d + ' ' + h + ':' + min + ':' + sec
				console.log(_this.current_year_month)
			},
			async ongetSwimInfo() {
				let params = {
					app_id: this.$https.weixinAppId,
					project_id: getApp().globalData.projectId,
					// open_id: uni.getStorageSync("openid"),
					out_code: this.out_code
				};
				let res = await person.getSwimInfo(params);
				if (res.code === 1) {
					this.overtimelist = res.data.result
					this.overinfo = true
					this.getCurrentTime()
				} else {
					uni.showToast({
						icon: 'none',
						title: res.info
					})
				}
			},
			async gogetSwimInfo(){
				let that = this
				// 扫呗
				let res = await person.getPriceAndPostOrder({
					id: this.overtimelist.id,
					app_id: this.$https.weixinAppId,
					project_id: getApp().globalData.projectId,
				})
				if (res.code == 1) {
					this.orderlist = res.data.data
					console.log(this.orderlist,'this.orderlist')
					uni.navigateTo({
						url: "/page_venues/pages/venuesDetail/pay/payover?amount=" + that.orderlist.goods_amout +"&venue_id=" +
							that.orderlist.venue_id + "&order_id=" + that.orderlist.order_no +
							"&orderid=" +
							that.orderlist.order_number + "&order_type=" + that.orderlist.order_type +
							"&chaoshitype=" + 2+ "&goods_id=" + that.overtimelist.id,
					
					});
				}
			},
		}
	}
</script>

<style scoped lang="scss">
	.control {
		width: 100%;
		min-height: 100vh;
		background-color: #EDF5F5;
		position: relative;

		.control_cen {
			display: flex;
			flex-direction: column;
			padding: 20rpx 20rpx;
			background-color: #fff;
			margin: 20rpx 20rpx 0 20rpx;

			.con_bet {
				display: flex;
				flex-direction: row;
				align-items: center;
				padding: 10rpx 20rpx;

				.con_l {
					font-size: 26rpx;
				}

				.con_r {
					font-size: 26rpx;
					margin-left: 20rpx;
				}

				.con_btn {
					font-size: 26rpx;
					margin-left: 20rpx;
				}
			}
		}

		.go-btn {
			position: fixed;
			bottom: 30rpx;
			left: 5%;
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			height: 80rpx;
			width: 90%;

			.on-btn {}

			.btn {
				width: 200rpx;
				height: 80rpx;
				background: linear-gradient(270deg, #57C08B 0%, #69D1A4 100%);
				border-radius: 40rpx;
				color: #fff;
				text-align: center;
				font-size: 28rpx;
				line-height: 80rpx;
			}
		}

	}
</style>